<template>
  <div>
    <el-table
        ref="singleTable"
        :border="true"
        :data="list"
        highlight-current-row
        max-height="680"
        style="width: 100%"
    >
      <el-table-column label="序号" sortable type="index" width="50">
      </el-table-column>
      <el-table-column label="课程名称" sortable width="200">
        <template slot-scope="scope">
              <span
                  style="color: #00a0e9; cursor: pointer"
                  @click="handleGetActivityInfo(scope.row.courseId)"
              >
                {{ scope.row.courseName }}</span
              >
        </template>
      </el-table-column>
      <el-table-column
          label="课程描述"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.courseDisc }}</span>
        </template>
      </el-table-column>
      <el-table-column
          label="课程人数"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.coursePeople }}</span>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        :current-page="currentPage"
        :page-size="currentPageSize"
        :page-sizes="[10, 50, 100, 500, 1000, 99999]"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleGetBySizeActivity"
        @current-change="handleGetByNumActivity"
    />
  </div>
</template>
<script>
import navBtn from "@/components/navBtn";

export default {
  props: ["status"],
  data () {
    return {
      list: [],
      currentPage: 1,
      currentPageSize: 10,
      total: 0,
      keyword: "",
      dataRange: null,
      articleContentshow: false,
      sheet_list: [],
      signShow: false,
      signImg: "",
      searchTime: null,
      auditShow: false,
      auditRes: null,
      auditReason: null,
      refuseReason: false,
      articleShow: false,
      tmpActivityId: "",
    };
  },
  mounted () {
    this.handleGetByNumActivity(1, this.status);
  },
  components: {
    navBtn,
  },
  methods: {
    // 格式化成为表格所需要的数据
    async handleGetBySizeActivity (size) {
      this.currentPageSize = size;
      let status = this.status;
      await this.handleGetActivity(status);
    },

    // 分页查询全部活动
    async handleGetByNumActivity (num) {
      this.currentPage = num;
      let status = this.status;
      await this.handleGetActivity(status);
    },
    async handleGetActivityInfo (params) {
      this.$emit("handleGetActivityInfo", params);
    },
    // 分页查询已完成的活动
    async handleGetActivity (status) {
      let pageSize = this.currentPageSize;
      let pageNumber = this.currentPage;
      const res = await this.$http.courseFGetCourseByStatus({
        pageNumber,
        pageSize,
        status,
      });
      if (res.code !== 0) return null;
      this.list = res.data.list;
      this.total = res.data.totalCount;
    },
    async handleActivityRecordList (id) {

      const res = await this.$http.activity_recordList(id);
      if (res.code !== 0) return null;

    },
  },
};
</script>
